function createTheme() {
	Highcharts.theme = {
		colors : [ '#D92940', '#058DC7', '#50B432', '#DDDF00', '#24CBE5',
				'#64E572', '#FF9655', '#FFF263', '#6AF9C4' ],
		chart : {
			borderWidth : 0,
			plotBackgroundColor : 'rgba(255, 255, 255, .9)',
			plotShadow : true,
			plotBorderWidth : 1
		},
		title : {
			style : {
				color : '#000',
				font : 'bold 16px "Trebuchet MS", Verdana, sans-serif'
			}
		},
		subtitle : {
			style : {
				color : '#666666',
				font : 'bold 12px "Trebuchet MS", Verdana, sans-serif'
			}
		},
		xAxis : {
			gridLineWidth : 1,
			lineColor : '#000',
			tickColor : '#000',
			labels : {
				style : {
					color : '#000',
					font : '11px Trebuchet MS, Verdana, sans-serif'
				}
			},
			title : {
				style : {
					color : '#333',
					fontWeight : 'bold',
					fontSize : '12px',
					fontFamily : 'Trebuchet MS, Verdana, sans-serif'

				}
			}
		},
		yAxis : {
			minorTickInterval : 'auto',
			lineColor : '#000',
			lineWidth : 1,
			tickWidth : 1,
			tickColor : '#000',
			labels : {
				style : {
					color : '#000',
					font : '11px Trebuchet MS, Verdana, sans-serif'
				}
			},
			title : {
				style : {
					color : '#333',
					fontWeight : 'bold',
					fontSize : '12px',
					fontFamily : 'Trebuchet MS, Verdana, sans-serif'
				}
			}
		},
		legend : {
			itemStyle : {
				font : '9pt Trebuchet MS, Verdana, sans-serif',
				color : 'black'

			},
			itemHoverStyle : {
				color : '#039'
			},
			itemHiddenStyle : {
				color : 'gray'
			}
		},
		labels : {
			style : {
				color : '#99b'
			}
		}
	};
	return Highcharts.theme;
}
var highchartsOptions = Highcharts.setOptions(createTheme());
// Apply the theme

// On document ready, call visualize on the datatable.

function createOptionsSeriesType(seriesType) {
	var options = null;
	if (seriesType == "column") {
		options = {
			chart : {
				renderTo : 'container',
				defaultSeriesType : 'column',
				width:780
			},
			title : {
				text : ''
			},
			xAxis : {
				title : {
					text : ''
				}
			},
			yAxis : {
				title : {
					text : ''
				}
			},
			tooltip : {
				formatter : function() {
					return this.series.name + "/" + this.x + "<br/>" + this.y;
				}
			},
			series : []
		};
	} else if (seriesType == 'stackedColumn') {
		options = {
			chart : {
				renderTo : 'container',
				defaultSeriesType : 'column',
				width:780
			},
			title : {
				text : ''
			},
			xAxis : {
				categories : [],
				title : {
					text : ''
				}
			},
			yAxis : {
				min : 0,
				title : {
					text : ''
				},
				stackLabels : {
					enabled : true,
					style : {
						fontWeight : 'bold',
						color : (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
					}
				}
			},
			legend : {
				align : 'center',
				x : 0,
				verticalAlign : 'bottom',
				y : 0,
				floating : false,
				backgroundColor : (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
				borderColor : '#CCC',
				borderWidth : 1,
				shadow : false
			},
			tooltip : {
				formatter : function() {
					return '<b>' + this.x + '</b><br/>' + this.series.name
							+ ': ' + this.y + '<br/>' + 'Total: '
							+ this.point.stackTotal;
				}
			},
			plotOptions : {
				column : {
					stacking : 'normal',
					dataLabels : {
						enabled : true,
						color : (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
					}
				}
			},
			series : []
		};
	} else if (seriesType == 'spline') {
		options = {
			chart : {
				renderTo : 'container',
				defaultSeriesType : 'spline',
				width:780
			},
			title : {
				text : ''
			},
			subtitle : {
				text : ''
			},
			xAxis : {
				categories : [],
				title : {
					text : ''
				}
			},
			yAxis : {
				title : {
					text : ''
				},
				labels : {
					formatter : function() {
						return this.value + ''
					}
				},
				min : 0

			},
			tooltip : {
				crosshairs : true,
				shared : true
			},
			plotOptions : {
				spline : {
					marker : {
						radius : 4,
						lineColor : '#666666',
						lineWidth : 1
					}
				}
			},
			series : []
		};
	}else{
		//column-stacked-and-grouped.
		if(seriesType == "stacked_Grouped_column"){
			options = {
			chart : {
				renderTo : 'container',
				defaultSeriesType : 'column',
				width:780
			},
			title : {
				text : ''
			},
			xAxis : {
				categories : [],
				title : {
					text : ''
				}
			},
			yAxis : {
				min : 0,
				title : {
					text : ''
				},
				stackLabels : {
					enabled : true,
					style : {
						fontWeight : 'bold',
						color : (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
					}
				}
			},
			legend : {
				align : 'center',
				x : 0,
				verticalAlign : 'bottom',
				y : 0,
				floating : false,
				backgroundColor : (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
				borderColor : '#CCC',
				borderWidth : 1,
				shadow : false
			},
			tooltip : {
				formatter : function() {
					return '<b>' + this.x + '</b><br/>' + this.series.name
							+ ': ' + this.y + '<br/>' + 'Total: '
							+ this.point.stackTotal;
				}
			},
			plotOptions : {
				column : {
					stacking : 'normal',
					dataLabels : {
						enabled : true,
						color : (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
					}
				}
			},
			series : []
		};
		}
	}
	return options;
}

function initLeftMemu(){
	var leftBox = $("#leftBox");
	leftBox.append("<a align='center'>2011 LTx VS 2010</a>");
	
}
function initBox() {
	initLeftMemu();
	var year = new Date().getFullYear();
	//year=2028;
	var yearSpan = $("#P114");
	yearSpan.append("<input type='checkbox' name='P114' value='100'>&nbsp;全部</input>&nbsp;");
	for ( var i = year; i >= year-4; i--) {
		yearSpan.append("<input type='checkbox' name='P114' value=" + i + ">&nbsp;" + i + "</input>&nbsp;");
	}
	yearSpan.append("<input type='checkbox' name='otherYear' value='0'>&nbsp;其它年份</input>&nbsp;");
	$(":checkbox[name='otherYear']").bind('click',function(){
		if(this.checked){
			if(year-2007<5){
				alert("目前没有其它年份的数据！");
				this.checked=false;
			}else{
				var otherYearBox=$("#otherYear");
				otherYearBox.html("");
				for(var i=year-5,j=0;i>=2007;i--,j++){
					if(j%6 ==0){
						//alert($.browser.webkit +" "+$.browser.safari+" "+window.chrome);
						if($.browser.msie || ($.browser.webkit && !window.chrome)){
							otherYearBox.append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
						}else{
							otherYearBox.append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
						}
					}
					$("#otherYear").append("<input type='checkbox' name='P114' value=" + i + ">&nbsp;" + i + "</input>&nbsp;");
				}
			}
		}else{
			$("#otherYear").html("");
		}
	});
	var monthSpan = $("#P115");
	for ( var i = 1; i <= 12; i++) {
		monthSpan.append("<input type='checkbox' name='P115' value='" + (i < 10 ? "0" + i : i) + "'>&nbsp;"+ (i < 10 ? "0" + i : i) + "</input>&nbsp;");
	}
	monthSpan.append("<option value='100'>全部</option>");
	var txSpan = $("#P105");
	txSpan.append("<input type='checkbox' name='P105' value='100'>&nbsp;全部</input>&nbsp;"+ 
				  "<input type='checkbox' name='P105' value='1'>&nbsp;肝</input>&nbsp;" +
				  "<input type='checkbox' name='P105' value='2'>&nbsp;肾</input>&nbsp;"
				+ "<input type='checkbox' name='P105' value='3'>&nbsp;心</input>&nbsp;"
				+ "<input type='checkbox' name='P105' value='4'>&nbsp;肺</input>&nbsp;"
				+ "<input type='checkbox' name='P105' value='5'>&nbsp;小肠</input>&nbsp;"
				+ "<input type='checkbox' name='P105' value='6'>&nbsp;其它</input>&nbsp;");

	var donnorSrc = $("#P112").append("<input type='checkbox' name='P112' value='100'>&nbsp;全部</input>&nbsp;"+
									  "<input type='checkbox' name='P112' value='1'>&nbsp;活体</input>&nbsp;"+
									  "<input type='checkbox' name='P112' value='2'>&nbsp;尸体</input>&nbsp;");

	var deadDonnor = $("#P113").append("<input type='checkbox' name='P113' value='100'>&nbsp;全部</input>&nbsp;"+
									   "<input type='checkbox' name='P113' value='1'>&nbsp;社会捐献</input>&nbsp;" +
									   "<input type='checkbox' name='P113' value='2'>&nbsp;司法途径</input>&nbsp;");

	var medicalSolution = $("#P118").append("<input type='checkbox' name='P118' value='100'>&nbsp;全部</input>&nbsp;"+
											"<input type='checkbox' name='P118' value='1'>&nbsp;CNI为基础方案</input>&nbsp;" +
											"<input type='checkbox' name='P118' value='2'>&nbsp;非CNI为基础方案</input>&nbsp;");

	var medical = $("#P119").append("<input type='checkbox' name='P119' value='100'>&nbsp;全部</input>&nbsp;"+
									"<input type='checkbox' name='P119' value='1'>&nbsp;普乐可复</input>&nbsp;" +
									"<input type='checkbox' name='P119' value='2'>&nbsp;新普乐可复</input>&nbsp;"+ 
								    "<input type='checkbox' name='P119' value='3'>&nbsp;华东Tac</input>&nbsp;" +
								    "<input type='checkbox' name='P119' value='4'>&nbsp;海正Tac</input>&nbsp;");
						if($.browser.msie || ($.browser.webkit && !window.chrome)){
							$("#P119").append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
						}else{
							$("#P119").append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
						}
					$("#P119").append("<input type='checkbox' name='P119' value='5'>&nbsp;其它厂家Tac</input>&nbsp;"+ 
								    "<input type='checkbox' name='P119' value='6'>&nbsp;新山地明</input>&nbsp;" +
								    "<input type='checkbox' name='P119' value='7'>&nbsp;国产CsA</input>&nbsp;");
	$(":checkbox").live('click',function(){
		if(this.value ==100 ){
			if( this.checked){
				$(":checkbox[name="+this.name+"]").attr('checked',true);
				if(this.name=='P112'){
					$(":checkbox[name=P113]").attr('checked',false);
					$("#P113").css('visibility','hidden');
				}else if(this.name="P118"){
					$(":checkbox[name=P119]").attr('checked',false);
					$("#P119").css('visibility','hidden');
				}
			}
		}else if(this.value !=100){
			if(!this.checked){
				$(":checkbox[name="+this.name+"][value=100]").attr('checked',false);
				if(this.name=='P112' ){
					if( this.value==2){
						$("#P113").css('visibility','hidden');
						$(":checkbox[name=P113]").attr('checked',false);
					}else{
						if($(":checkbox[name="+this.name+"][value=2]").attr('checked')){
							$("#P113").css('visibility','visible');
						}
					}
				}else if(this.name=='P118'){
					if( this.value==1){
						$("#P119").css('visibility','hidden');
						$(":checkbox[name=P119]").attr('checked',false);
					}else if(this.value==2){
						if($(":checkbox[name=P118][value=1]").attr('checked')){
							$("#P119").css('visibility','visible');
						}
					}
				}
			}else{				
				if(this.name=='P112' ){
					if(this.value==2){
						if($(":checkbox[name=P112][value=1]").attr('checked')){
							$("#P113").css('visibility','hidden');
							$(":checkbox[name=P113]").attr('checked',false);
						}else{
							$("#P113").css('visibility','visible');
						}
					}else{
						$("#P113").css('visibility','hidden');
						$(":checkbox[name=P113]").attr('checked',false);
					}
				}else if(this.name=='P118'){
					if(  this.value==1){
						if($(":checkbox[name=P118][value=2]").attr('checked')){
							$("#P119").css('visibility','hidden');
							$(":checkbox[name=P119]").attr('checked',false);
						}else{
							$("#P119").css('visibility','visible');
						}
					}else{
						$("#P119").css('visibility','hidden');
						$(":checkbox[name=P119]").attr('checked',false);
					}
				}
				
				var flag=true;
				$(":checkbox[name="+this.name+"][value!=100]").each(function(i,n){
					if(!n.checked){
						flag=false;
						return flag;
					}
				});
				if(flag){
					$(":checkbox[name="+this.name+"][value=100]").click();
				}
			}
		}
	});
	
	$(":button[name='columnChartBtn']").live('click', function() {
			var data=createDataToUrl();
			document.getElementById("chartContainer").innerHTML = "";		
			createTableAndChart(data,"column");
	});
	$(":button[name='splineChartBtn']").live('click', function() {		
			var data=createDataToUrl();	
			document.getElementById("chartContainer").innerHTML = "";			
			createTableAndChart(data,"spline");
	});
	$(":button[name='stackedChartBtn']").live('click', function() {
			var data=createDataToUrl();
			document.getElementById("chartContainer").innerHTML = "";
			if(stackedGroup<1){
				createTableAndChart(data,"stackedBar");
			}else{
				createTableAndChart(data,"stacked_Grouped_column");
			}
	});
}

var stackedGroup=-1;
//生成json格式的数据向url传值
function createDataToUrl(){
	var data="";
	var newData=data;
	stackedGroup=-1;//统计全选被选中的个数
	//通过表单对象名取其值（当全选框被选中时，取其下所有的值）
	function getAllValueByObject(objectName){
		var value="";
		$(":checkbox[name="+objectName+"][value !=100]").each(function(i,n){
			 value+=n.value+",";
		});
		value=value.substr(0,value.length-1);
		return value;
	}
	//重新组装表单数据(全部数据以字符形式组装，此处截掉最后一个','并添加'',')
	function rebuildUrl(){
		if(newData !=data){
			newData=newData.substr(0,newData.length-1)+"',";	
			data=newData;
		}
	}	
	//通过表单对象名取复选框被选中的值并组装
	function buildUrlByObject(objectName){
		$(":checkbox[name="+objectName+"][checked]").each(function(i,n){
			//组装表单数据
			if(i==0) newData+="'"+n.name+"':'";
			if(n.value != 100) {
				newData+=n.value+",";
			}else{
				stackedGroup++;
				data+="'"+n.name+"':'"+getAllValueByObject(n.name)+"',";
				newData =data;
				return false;
			}
		});
		rebuildUrl();
	}
	buildUrlByObject('P114');
	buildUrlByObject('P105');
	buildUrlByObject('P112');
	buildUrlByObject('P113');
	buildUrlByObject('P118');
	buildUrlByObject('P119');
	//判断选择全部的个数	
	data=eval("({"+data.substr(0,data.length-1)+"})");
	return data;
}
//生成图和表
function createTableAndChart(data,seriesType){
	var msg =getData(data);
	var options = createOptions(msg,seriesType);
	createAnnualContrastTable(options.xAxis.categories,options.series);
	//createDataTable(options.xAxis.categories,options.series);
	createInValidTable(msg);
	createChart(options);
}
//向服务器请求数据
function getData(condition) {
	var msg="";
	$.ajax( {
				url : getActionUrl("getChart2_1_0_1"),
				type : "POST",
				dataType : 'json',
				async : false,
				data :  condition ,
				success : function(jd) {
				//alert(this.data);
					msg=jd;	
					$("#chartContainer").append("<div align='center' id='container' style='width: 780px;  margin: 0 auto;'></div>"+
												"<div><div align='right' class='showTableDiv'>展开年度对比列表</div>" +
												"<div id='dataAnnualContrastDiv' style='display:none'></div><div>" +
												"<div><div align='right' class='showTableDiv'>展开数据统计列表</div>" +
												"<div id='datatableDiv' style='display:none'></div><div>" +
												"<div><div align='right' class='showTableDiv'>展开剔除数据列表</div>" +
												"<div id='invalidTableDiv' style='display:none' align='center'></div><div>");
					$(".showTableDiv").bind('click',function(){
						var label=$(this).text().substr(2,$(this).text().length);
						if($(this).next().css('display')=='none'){
							$(this).text('关闭'+label);
						}else{
							$(this).text('展开'+label);
						}
						$(this).next().toggle();
					});
				},
				error : function() {
					alert('加载数据失败，请检查网络问题！');
				}
			});
	return msg;
}
//初始化统计图的展示形式及数据
function createOptions(msg,seriesType){
		if ($.browser.msie) {
			$("body").removeClass();
			$("#chartContainer").removeClass();
		}
		//var headTitle = "<br><div align='center'><font  style='font-family: 宋体 ;font-weight: bold;font-size:18px;'></div>";
		//$("#chartContainer").append(headTitle + '<br/>');
		var seriesData = ""; //按series的格式{name:name,data:data}接收数据，最终转成json格式
		//var xAxisCategories = "";//X轴要展现的数据
		for ( var i = 0; i < msg.valid.length; i++) {
			var dataMember = "";//每一个图例中要展示的数据
			for ( var j = 0; j < msg.valid[i].month.length; j++) {
				dataMember += msg.valid[i].month[j] + ",";//按数组的长度来分别接收年份下每个月的数据
			}
			//此处根据年份的年度数（通常为2）来组装seriesData的数据
			seriesData += "{name:'"	+ msg.valid[i].legend	+ "',data:["+ dataMember.substring(0, dataMember.length - 1)+ "]},";
		}
		var options = createOptionsSeriesType(seriesType);
		options.xAxis.categories = eval("(['Jan','Feb','Mar','Apr','May','Jun','July','Aug','Sep','Oct','Nov','Dec'])");//将读取到的数据转成json数组格式
		options.series = eval("["+ seriesData.substring(0, seriesData.length - 1)+ "]");//将图例数据部分转成json数组格式
		options.xAxis.title.text = "Time(M)";
		var tx = msg.valid[0].txType == 1 ? 'LTx': (msg.valid[0].txType == 2 ? "KTx": msg.valid[0].txType);
		options.title.text = msg.valid[0].legend + " " + tx	+ " Number Stat. By Month";
		options.yAxis.title.text = tx + " No.";
		return options;
}
//生成统计图
function createChart(options) {		
		chart = new Highcharts.Chart(options);//将此格式的options作为参数传给highcharts的Chart方法来生成chart实例
}
function createAnnualContrastTable(xAxis,series){	
	$("#dataAnnualContrastDiv").append('<table class="mintable" align="left"  id="dataAnnualContrastTable" width="780px" border="1" ></table><br/><br/>');
	$("#dataAnnualContrastTable").append("<tr><th></th><th>Jan</th><th>Feb</th><th>Mar</th><th>Apr</th><th>May</th><th>Jun</th><th>July</th><th>Aug</th><th>Sep</th><th>Oct</th><th>Nov</th><th>Dec</th>");
	for(var j=0;j<series.length;j++){
		var nextTr ="";
		if(j!=0){
			nextTr+="<th>VS "+series[j].name+"</th>";
		}else{
			nextTr+="<th> "+series[j].name+"</th>";
		}
		for ( var i = 0; i < xAxis.length; i++) {
			if(j!=0){
				nextTr += "<td>"	+series[j].data[i]+"<br/>"+leftTwoDecIgnoreZeroWithBracket(series[0].data[i] / series[j].data[i]* 100) +"</td>";
			}else{
				nextTr += "<td>"	+series[j].data[i]+"</td>";
			}
		}
		$("#dataAnnualContrastTable").append("<tr>"+nextTr+"</tr>");
	}
}
function createDataAndAnnualContrastTable(xAxis,series){	
	$("#datatableDiv").append('<table class="mintable"  align="left" id="datatable" border="1" width="780px" ></table><br/><br/>');
	$("#datatable").append("<tr><th>Year</th><th>Jan</th><th>Feb</th><th>Mar</th><th>Apr</th><th>May</th><th>Jun</th><th>July</th><th>Aug</th><th>Sep</th><th>Oct</th><th>Nov</th><th>Dec</th>");
	for(var j=0;j<series.length;j++){
		var secondTd = "<th>"+series[j].name+"</th>";
		for ( var i = 0; i < xAxis.length; i++) {
			secondTd += "<td>"	+ series[j].data[i] + "</td>";
		}
		$("#datatable").append("<tr>"+secondTd+"</tr>");
	}
}
/*
//年度对比数据列表
  function createAnnualContrastTable(xAxis,series){	
	$("#dataAnnualContrastDiv").append('<table class="mintable" align="left"  id="dataAnnualContrastTable" width="780px" border="1" ></table><br/><br/>');
	$("#dataAnnualContrastTable").append("<tr><th>Vs</th><th>Jan</th><th>Feb</th><th>Mar</th><th>Apr</th><th>May</th><th>Jun</th><th>July</th><th>Aug</th><th>Sep</th><th>Oct</th><th>Nov</th><th>Dec</th>");
	for(var j=1;j<series.length;j++){
		var nextTr = "<th>"+series[j].name+"</th>";
		for ( var i = 0; i < xAxis.length; i++) {
			nextTr += "<td>"	+ leftTwoDecIgnoreZero(series[0].data[i] / series[j].data[i]* 100) + "</td>";
		}
		$("#dataAnnualContrastTable").append("<tr>"+nextTr+"</tr>");
	}
}
function createDataTable(xAxis,series){	
	$("#datatableDiv").append('<table class="mintable"  align="left" id="datatable" border="1" width="780px" ></table><br/><br/>');
	$("#datatable").append("<tr><th>Year</th><th>Jan</th><th>Feb</th><th>Mar</th><th>Apr</th><th>May</th><th>Jun</th><th>July</th><th>Aug</th><th>Sep</th><th>Oct</th><th>Nov</th><th>Dec</th>");
	for(var j=0;j<series.length;j++){
		var secondTd = "<th>"+series[j].name+"</th>";
		for ( var i = 0; i < xAxis.length; i++) {
			secondTd += "<td>"	+ series[j].data[i] + "</td>";
		}
		$("#datatable").append("<tr>"+secondTd+"</tr>");
	}
}*/
//剔除数据列表
function createInValidTable(msg) {
	var invalid = msg.invalid;
	var invalidTableDiv = $("#invalidTableDiv");
	invalidTableDiv.append("<table>");
	for ( var i = 0; i < invalid.length; i++) {
		var title = invalid[i].legend+"  "+getNameByValue(msg.valid[i].txType)+"  数据剔除情况列表";
		var inData = invalid[i].invalidData;
		invalidTableDiv.append("<tr><td align='center'>");
		invalidTableDiv.append("<div align='center'>"+ title+ "</div>"
						+ "<div align='center'><table class='mintable' border='1' align='left' id='datatable"+ i+ "' width='780px' >"
						+ "<tr><th>数据情况</th><th>数量(例)</th><th>占选取数据比例(%)</th><th>涉及中心数(家)</th><th>处理结果</th></tr></table><br/></div>");
		var tr = "";
		var total = inData[0].number1;
		for ( var j = 0; j < inData.length; j++) {
			tr += "<tr><th>" + inData[j].label + "</th><td>"+ inData[j].number1 + "</td><td>"+ leftTwoDec(inData[j].number1 / total * 100) + "%</td>"
					+ "<td>" + inData[j].number2 + "</td><td>"+ inData[j].operator + "</td></tr>";
		}
		$("#datatable" + i).append(tr);
		invalidTableDiv.append("</td></tr>");
	}
	invalidTableDiv.append("</table><br/><br/> ");

}
function getNameByValue(value){
	if(value==1){
		return "LTx";
	}else if(value==2){
		return "KTx";
	}else {
		return "";
	}
}
function leftTwoDec(x) {
	return Math.round(x * 100) / 100;
}
function leftTwoDecIgnoreZero(x) {
	var f = Math.round(x * 100) / 100;
	return (f > 0 && (f != "Infinity") && !f.NaN) ? (f < 100 ? '<font color="red">' + f + "%" : f + "%") : '';
}

function leftTwoDecIgnoreZeroWithBracket(x) {
	var f = Math.round(x * 100) / 100;
	return (f > 0 && (f != "Infinity") && !f.NaN) ? (f < 100 ? '<font color="red">(' + f + "%)" :"("+ f + "%)") : '';
}